package com.kaibes.platform.article.admin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.kaibes.platform.article.db.service.ArticleCategoryService;
import com.kaibes.platform.article.db.service.ArticleCommentService;
import com.kaibes.platform.article.db.service.ArticleService;
import com.kaibes.platform.article.db.service.ArticleTagService;
import com.kaibes.web.admin.IconBox;

@Configuration
public class ArticleBoxInit {

	@Autowired
    private ArticleService articleService;
    @Autowired
    private ArticleCommentService articleCommentService;
    @Autowired
    private ArticleCategoryService articleCategoryService;
    @Autowired
    private ArticleTagService articleTagService;
    
    @Bean
    public IconBox articleBox() {
        IconBox iconBox = new IconBox() {

            @Override
            public void update() {
                setCount(articleService.count());
            }
        };
        iconBox.setSort(11);
        iconBox.setName("文章总数");
        iconBox.setClassAppend("bg-info");
        iconBox.setIcon("ion-clipboard");
        iconBox.setHref("/admin/article/view");
        return iconBox;
    }
    
    @Bean
    public IconBox commentBox() {
        IconBox iconBox = new IconBox() {

            @Override
            public void update() {
                setCount(articleCommentService.count());
            }
        };
        iconBox.setSort(12);
        iconBox.setName("评论总数");
        iconBox.setClassAppend("bg-olive");
        iconBox.setIcon("ion-chatbubbles");
        iconBox.setHref("/admin/article/comment");
        return iconBox;
    }
    
    @Bean
    public IconBox categoryBox() {
        IconBox iconBox = new IconBox() {

            @Override
            public void update() {
                setCount(articleCategoryService.count());
            }
        };
        iconBox.setSort(13);
        iconBox.setName("分类总数");
        iconBox.setClassAppend("bg-pink");
        iconBox.setIcon("ion-bookmark");
        iconBox.setHref("/admin/article/category");
        return iconBox;
    }
    
    @Bean
    public IconBox tagBox() {
        IconBox iconBox = new IconBox() {

            @Override
            public void update() {
                setCount(articleTagService.count());
            }
        };
        iconBox.setSort(14);
        iconBox.setName("标签总数");
        iconBox.setClassAppend("bg-maroon");
        iconBox.setIcon("ion-pricetags");
        iconBox.setHref("/admin/article/tag");
        return iconBox;
    }

}
